import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 节点资源信息 */
export interface KnowledgeNodeResource {
          id: number; // 编号
          nodeId?: number; // 节点ID
          title?: string; // 标题
          content?: string; // 描述
          url?: string; // 文件url
          resourceType?: string; // 资源类型
          sort?: number; // 排序
          status?: number; // 状态
  }

// 节点资源 API
export const KnowledgeNodeResourceApi = {
  // 查询节点资源分页
  getKnowledgeNodeResourcePage: async (params: any) => {
    return await request.get({ url: `/school/knowledge-node-resource/page`, params })
  },

  // 查询节点资源详情
  getKnowledgeNodeResource: async (id: number) => {
    return await request.get({ url: `/school/knowledge-node-resource/get?id=` + id })
  },

  // 新增节点资源
  createKnowledgeNodeResource: async (data: KnowledgeNodeResource) => {
    return await request.post({ url: `/school/knowledge-node-resource/create`, data })
  },

  // 修改节点资源
  updateKnowledgeNodeResource: async (data: KnowledgeNodeResource) => {
    return await request.put({ url: `/school/knowledge-node-resource/update`, data })
  },

  // 删除节点资源
  deleteKnowledgeNodeResource: async (id: number) => {
    return await request.delete({ url: `/school/knowledge-node-resource/delete?id=` + id })
  },

  /** 批量删除节点资源 */
  deleteKnowledgeNodeResourceList: async (ids: number[]) => {
    return await request.delete({ url: `/school/knowledge-node-resource/delete-list?ids=${ids.join(',')}` })
  },

  // 导出节点资源 Excel
  exportKnowledgeNodeResource: async (params) => {
    return await request.download({ url: `/school/knowledge-node-resource/export-excel`, params })
  },
}